#include <iostream>
#include <map>
#include <vector>

auto getRates() { return std::vector<int>{1, 2, 3, 4, 5}; }

auto getRates2() {
  return std::multimap<int, bool>{
      {1, true}, {2, false}, {3, true}, {4, false}, {5, true}};
}

void testRangedForLoop() {
  // 指定类型
  for (int rate : getRates()) {
    std::cout << rate << std::endl;
  }
  for (int &rate : getRates()) {
    rate *= 2;
  }
  // auto
  for (auto rate : getRates()) {
    std::cout << rate << std::endl;
  }
  for (auto &&rate : getRates()) {
    std::cout << rate << std::endl;
  }
  for (auto &rate : getRates()) {
    rate *= 2;
  }
  for (auto const &rate : getRates()) {
    std::cout << rate << std::endl;
  }
  // 结构话绑定
  for (auto &&[rate, isGood] : getRates2()) {
    std::cout << rate << " " << isGood << std::endl;
  }
}

int main(int argc, char *argv[]) {
  std::cout << "==== ch01 p08 ====" << std::endl;
  testRangedForLoop();
  return 0;
}
